package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.DeleteTechnicalRequest;
import keeto.com.vn.bms.network.response.DeleteTechnicalReponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

public class TaskDeleteTechnical  extends AbstractTask{
	private String ID;
	private String authenKey;
	private String Reason;

	public TaskDeleteTechnical(BMSListener listener, IBMSCore core, String iD, String reason,
			String authenKey) {
		super(listener, core);
		ID = iD;
		this.authenKey = authenKey;
		this.Reason = reason;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		DeleteTechnicalRequest request = new DeleteTechnicalRequest();
		request.setAuthKey(authenKey);
		request.setID(ID);
		request.setReason(Reason);
		DeleteTechnicalReponse reponse = protocol.getDeleteTechnical(request);
		for (BMSListener mListener : listener){
			mListener.finishDeleteTechnical(reponse.getReturnCode(), reponse.getResultMsg());
		}
	}

	@Override
	public void timeoutCallback() {
		for (BMSListener mListener : listener){
			mListener.finishDeleteTechnical(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "");
		}
	}

}
